<div class="Item hr">
    <span class="fr">系统现有数据 <b>{$rows_count}</b> 行</span>
    <div class="current"><b>{$model['name']}</b> 数据列表</div>
</div>
<form class="list-body">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td width="90">
                    <input type="hidden" name="pk" value="{$pk[0]}" />
                    <label><input name="" class="chooseAll" type="checkbox"/> 全选</label> <label><input name="" class="unsetAll" type="checkbox"/> 反选</label></td>
                <volist name="fields" id="field">
                    <td>{$field['comment']}</td>
                </volist>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="rows" id="row">
            <tr align="center">
                <volist name="fields" id="field">
                    <if condition="$pk[0] eq $field['name']">
                        <td><input type="checkbox" name="{$pk[0]}[]" value="{$row[$pk[0]]}"/></td>
                    </if>
                    <if condition="$field['show_type'] eq img">
                        <td><img width="50px" src="{$row[$field['name']]}"></td>
                    <else/>
                        <td>{$row[$field['name']]}</td>
                    </if>
                </volist>
                <td>[ <a href="{:U(CONTROLLER_NAME . '/edit', array('id' => $row['id']))}">编辑</a> ] [ <a href="javascript:void(0);" value="{:U(CONTROLLER_NAME . '/delete', array('id' => $row['id']))}" name="ID={$row['id']}" class="del">删除</a> ]</td>
            </tr>
            </volist>
        </tbody>

        <if condition="count($rows) gt 15">
            <tfoot align="center">
                <tr>
                    <td width="90"><label><input name="" class="chooseAll" type="checkbox"/> 全选</label> <label><input name="" class="unsetAll" type="checkbox"/> 反选</label></td>
                    <volist name="fields" id="field">
                        <td>{$field['comment']}</td>
                    </volist>
                    <td>操作</td>
                </tr>
            </tfoot>
        </if>
    </table>
</form>

<div class="page">
    {$page}
</div>

<div class="commonBtnArea" >
    <span>批量操作：</span>
    <select id="multiopt">
        <option value="delete">删除</option>
    </select>
    <button class="btn multiedit">确定</button>
</div>

<script type="text/javascript">
$(function(){
    clickCheckbox();
    $(".del").click(function(){
        var del_link = $(this).attr("value");
        popup.confirm('您真的打算删除 '+$(this).attr("name")+' 的数据吗?','温馨提示',function(action){
            if(action == 'ok'){
                $.getJSON(del_link, function(json){
                    if (json.status) {
                        popup.success(json.info);
                        setTimeout(function(){
                            popup.close("asyncbox_success");
                        },2000);
                    } else {
                        popup.error(json.info);
                        setTimeout(function(){
                            popup.close("asyncbox_error");
                        },2000);
                    }

                    setTimeout(function(){
                        top.window.location.reload();
                    },1000);
                });
            }
        });

        return false;
    });

    $(".multiedit").click(function () {
        var that = $(this);
        var m_type = $("#multiopt").val();

        if($("tbody input[type='checkbox']:checked").size()==0){
            popup.alert("请先选择你要操作的数据吧");
            return false;
        }

        form = $("form.list-body");
        if(m_type == "delete") {
            form.append('<input name="edit_type" type="hidden" class="medit_element" value="delete" />')
        }

        commonAjaxSubmit("{:U(CONTROLLER_NAME.'/medit')}", "", function () {
            $(".medit_element").remove();
            setTimeout(function () {
                location.reload();
            }, 2000)
        });
    })
});
</script>
